package homework.course.role.state;


import homework.course.Message;
import homework.course.MessageType;
import homework.course.role.Student;

public class SleepState extends StudentState {

    public SleepState(Student student) {
        super(student, "睡觉", "开始睡觉");
    }

    @Override
    public String speak() {
        String msg = "呼呼Zzzzz";
        std.notifyObservers(new Message(msg, MessageType.WORDS));
        return msg;
    }

    @Override
    public void listen(Object obj, String msg) {
        if(Math.round(Math.random()*3) == 0) {
            std.notifyObservers(new Message("醒了", MessageType.SYSTEM));
            std.setState(std.getDistractedState());
        } else {
            std.notifyObservers(new Message("毫无反应", MessageType.SYSTEM));
        }
    }
}
